package com.doucat.support.component.recycle.holder;

import android.view.View;

import androidx.collection.SparseArrayCompat;
import androidx.recyclerview.widget.RecyclerView;

/**
 * -----------------------------------------------------------------
 * Copyright (C) 2014-2016, by your company, All rights reserved.
 * -----------------------------------------------------------------
 * File: BaseRecyclerHolder.java
 * Author: win7
 * Version: V100R001C01
 * Create: 2021/1/26 11:05
 * Changes (from 2021/1/26)
 * -----------------------------------------------------------------
 * 2021/1/26 : Create BaseRecyclerHolder.java (win7);
 * -----------------------------------------------------------------
 */

public class BaseRecyclerHolder extends RecyclerView.ViewHolder {
    private SparseArrayCompat<View> mViews;

    public BaseRecyclerHolder(View itemView) {
        super(itemView);
        mViews = new SparseArrayCompat<>();
    }

    public <T extends View> T getView(int res){
        T v = (T) mViews.get(res);
        if (v == null){
            v = itemView.findViewById(res);
            mViews.put(res,v);
        }
        return v;
    }
}
